package whackEm.ui;

import whackEm.V2.WhackEmPanel;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;

public class EndScreen {
	
	public float top,leftResume,leftClose,height,width,bottom;
	private WhackEmPanel panel;
	private Bitmap endText;
	
	private RectF pauseRect;
	private Paint pauseRectPaint = new Paint();
	
	
	
	public EndScreen(Bitmap touchScreenToContinueBitmap,WhackEmPanel panel) {
		this.endText = touchScreenToContinueBitmap;		
		height =  panel.convertYforDrawable(endText.getHeight());
		width =  panel.convertXforDrawable(endText.getWidth());	
		this.panel = panel;
		setPosition();
		pauseRectPaint.setARGB(100, 51, 51, 51);		
	}
	
	public void setPosition() {		
		top = panel.convertY((400)) - height;
		bottom = top + height;		
		leftClose  = panel.convertX((240)) - width/2;
		pauseRect = new RectF( panel.convertX(20) , 
				top - panel.convertY(15), panel.convertY(460),  bottom+ panel.convertY(15));
		
	}
	
	
	public void update() {
		
	} 
	
	public void draw(Canvas canvas) {
		canvas.drawARGB(100,100,100,100);
		canvas.drawRoundRect(pauseRect, 15, 15, pauseRectPaint);		
		canvas.drawBitmap(endText, leftClose, top, null);
		
	} 
	
	public void handleActionDown(float x,float y) {
		if (y >= top && y<= bottom)
            if (x>=leftClose && x <= leftClose + width)
				panel.stopPlayingAndKillActivity();
				
		
	} 
	
}
